﻿@model MarbaleManagementStudio.Models.Configuration

@{
    ViewBag.Title = "Configuration";
    Layout = null;
}

<div class="modal-header">
    <h4 class="modal-title">Configuration</h4>
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="min-width: 10px !important;">&times;</button>
</div>
<div class="modal-body" style="width:900px">
   
@using (Html.BeginForm("UpdateConfiguration", "Game", FormMethod.Post))
{
    @Html.ValidationSummary(true)

    <fieldset>
        <div style="width: 800px;">
            <div style="width: 370px; float: left">
                <div class="editor-label">
                    @Html.LabelFor(model => model.StartInPhysicalTicketMode)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.StartInPhysicalTicketMode)
                    @Html.ValidationMessageFor(model => model.StartInPhysicalTicketMode)

                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.NumberOfCoins)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.NumberOfCoins)
                    @Html.ValidationMessageFor(model => model.NumberOfCoins)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.TicketPulseWidth)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.TicketPulseWidth)
                    @Html.ValidationMessageFor(model => model.TicketPulseWidth)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.TicketPulseGap)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.TicketPulseGap)
                    @Html.ValidationMessageFor(model => model.TicketPulseGap)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.ReverseDisplayDirection)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.ReverseDisplayDirection)
                    @Html.ValidationMessageFor(model => model.ReverseDisplayDirection)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.BalanceDelay)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.BalanceDelay)
                    @Html.ValidationMessageFor(model => model.BalanceDelay)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.MinSecondsBetweenRepeatPlay)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.MinSecondsBetweenRepeatPlay)
                    @Html.ValidationMessageFor(model => model.MinSecondsBetweenRepeatPlay)
                </div>
                <div class="editor-label">
                    @Html.LabelFor(model => model.OutOfServiceTheme)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.OutOfServiceTheme)
                    @Html.ValidationMessageFor(model => model.OutOfServiceTheme)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.CoinPulseWidth)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.CoinPulseWidth)
                    @Html.ValidationMessageFor(model => model.CoinPulseWidth)
                </div>
            </div>
            <div style="width: 370px; float: left">

                <div class="editor-label">
                    @Html.LabelFor(model => model.CoinPulseGap)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.CoinPulseGap)
                    @Html.ValidationMessageFor(model => model.CoinPulseGap)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.SensorInterval)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.SensorInterval)
                    @Html.ValidationMessageFor(model => model.SensorInterval)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.DisableTickets)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.DisableTickets)
                    @Html.ValidationMessageFor(model => model.DisableTickets)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.CardRetries)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.CardRetries)
                    @Html.ValidationMessageFor(model => model.CardRetries)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.DisplayLanguage)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.DisplayLanguage)
                    @Html.ValidationMessageFor(model => model.DisplayLanguage)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.MaxTicketPerGamePlay)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.MaxTicketPerGamePlay)
                    @Html.ValidationMessageFor(model => model.MaxTicketPerGamePlay)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.OutOfService)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.OutOfService)
                    @Html.ValidationMessageFor(model => model.OutOfService)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.GamePlayDuration)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.GamePlayDuration)
                    @Html.ValidationMessageFor(model => model.GamePlayDuration)
                </div>
            </div>
            </div>
    </fieldset>
}
</div>
<div class="modal-footer">
    <button id="update" type="button" class="btn btn-primary" onclick="SaveConfiguration(this)">Save</button>
    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>


<script>
    $(document).ready(function () {
        $('.modal-body').css({
            'width': '798px',
            'height': '500px',
            'overflow-y': 'scroll'
        });
    })
    function SaveConfiguration(btnClicked) {
        var $form = $(btnClicked).parents('form');
        $.ajax({
            type: "POST",
            url: $form.attr('action'),
            data: $form.serialize(),
            error: function (xhr, status, error) {
                //do something about the error
            },
            success: function (response) {
                //do something with response
                alert('Data saved');

            }
        });
        return false;// if it's a link to prevent post
    }
    var updatedArray = [];
    function UpdatedList(x) {
        if (!updatedArray.includes(x.rowIndex)) {
            updatedArray.push(x.rowIndex);
        }
    }
</script>
